<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
	.rowmargin{
		margin-bottom: 10px;
	}
	
	.border-bottom{
		border: none!important;
	}
	
</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="row rowmargin">
			<div class="col-xs-12 col-sm-12	col-md-12 col-lg-12 zlspadding" >
				<div class="lefttop">
					<div class="dbsx-top">
						<div class="heisblack">
							<span class="aimColor"></span>
							<span class="quickStyle">我的快捷方式</span>
						</div>
						<a title="添加快捷方式" class="bianji" onclick="reback();" style="display: none;">+添加快捷方式</a>
					</div>
					<ul class="boxList" id="shortCutBoxList">
					</ul>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-12 col-sm-12	col-md-6 col-lg-6 zlspadding rowmargin" >
				<label class="amountCount" id="amountCount"></label>
				<div class="lefttop">
					<div class="dbsx-top">
						<div class="heisblack">
							<span class="aimColor"></span>
							<span class="quickStyle">收件箱</span>
						</div>
					</div>
					<ul class="col-xs-12 col-sm-12	col-md-12 col-lg-12 dbsx-content" id="otherInbox-content">
					</ul>
				</div>
			</div>
			
			<div class="col-xs-12 col-sm-12	col-md-6 col-lg-6 zlspadding" >
				<div class="lefttop">
					<div class="dbsx-top">
						<div class="heisblack">
							<span class="aimColor"></span>
							<span class="quickStyle">二维码</span>
						</div>
					</div>
					<div class="erweimaContent">
						<div class="introduction">可使用二维码下载客户端，ios可在appstore搜索”碟普车贷“进行下载。</div>
						<div class="content erweima">
							<div class="row">
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
									<div class="erweimaaz">
										<span class="erweimaazTop">碟普车贷安卓端</span>
										<div><img alt="" src="${basePath}/img/az.png"></div>
									</div>
								</div>
								<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
									<div class="erweimapg">
										<span class="erweimapgTop">碟普车贷苹果端</span>
										<div><img alt="" src="${basePath}/img/ios.png"></div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
			</div>
		</div>

		
		<div class="noticecontent" id="emailContent" style="display: none;">
			<div class="noticecontent-con" id="emailcontent-con"></div>
		</div>

		<!-- public quote -->
		<%@include file="/jsp/comm_js_include.jsp"%>
		<!-- echarts -->
		<%@include file="/js/common-dpqc/dpqc-echarts/comm_echarts_include.jsp"%>

<!-- public quote -->
<script type="text/javascript">
	var intervalIndex;
	
	function windowResize(){
		//浏览器当前窗口文档body的总高度 包括border padding margin
	    var height = $(document.body).outerHeight(true)-60; 
	    var halfheight = height/2;
	    $(".lefttop").css("height",halfheight+"px");
	}
	
	$(window).resize(function() { 
		//浏览器当前窗口文档body的总高度
		windowResize();
	}); 
	
    $(document).ready(function () {
	    
	    intervalIndex = setInterval("getShortCutPage()", 50);
	    
	    otherInbox();//单条邮件
	    
	    getStationMessage();//pc邮件显示
	    getStationMessage_();
	    
	    windowResize(); //浏览器当前窗口文档body的总高度
	    
    });
    
    function reback(){
    	window.location.href="${basePath}/web/system/base/shortcutManage.jsp";
    }
    
	function getShortCutPage(){
		if(!top.powerId || top.powerId == '') {
			return;
		}
		clearInterval(intervalIndex);
		$.dpAjax({
			show:false,
	    	url:'${basePath}/BaseShortcutController/shorcutList',
 			data:{
 				"page":1,
 				"rows":16,
 				"homePage":1,
 				"powerId":top.powerId
 			},
 			success: function(datas){
				 var html = "";
				 var records = datas.result.rows;
				 if(records && records.length > 0){
					 for(var i in records){
						 var record = records[i];
						 if(i % 6 == 0) {
							html += '<div class="content contentsortcut"><div class="row"><div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><div class="content"><div class="row">'; 
						 }
						 html += '<a class="adeLength" onclick="top.getNavText(\'' + record.powerId + '\',\''+record.href + '\');"><div class="col-xs-4 col-sm-4 col-md-2 col-lg-2"><div class="'+record.imgUrl+' showshortCut" title="'+record.shortcutName + '">';
						 html += ''+record.shortcutName + '</div></div></a>';
						 if(i % 6 == 5) {
							html += '</div></div></div></div></div>';  
						 }
					 }
				 }
				 $('#shortCutBoxList').html(html);
				 
				 var adeLength = $('#shortCutBoxList').find(".adeLength").length;
				 var con = '<div class="addTab" onclick="reback();">+添加快捷方式</div><div class="addTabfont">您还没有添加任何快捷方式哦，设置快捷方式能使你的工作加倍有效率！</div>';
				 if(adeLength <= 0 ){
					 $('#shortCutBoxList').html(con);
				 }else{
					 $(".bianji").show();
				 }
				 
             }
	    });
	}    
    
   	var otherInbox = function()
   	{
   		setInterval(function(){
       		$.dpAjax({
       			show:false,
    	    	url:'${basePath}/SystemController/getOtherInboxMapper',
    			success: function(datas)
    			{
   					  var otherInbox = datas.result;
   					  if(otherInbox)
   					  {
   						layer.alert(otherInbox.contentInbox, {
   						  title: otherInbox.titleInbox,	
   						  closeBtn: 0,
   						  offset: 'rb'
   						}, function(){
   							upOtherInbox(otherInbox.replaceId);
   						});
   					  }
                }
   	   		});
   		},2700000);
      }
  	   
   	
   	//更新状态
   	var upOtherInbox = function(replaceId)
   	{
   		$.dpAjax({
   	    	url:'${basePath}/SystemController/upOtherInbox',
   			data:{"replaceId":replaceId},
   			success: function(datas)
   			{
   				otherInbox();
			 	return;
            }
   	   });
   	}
   	
   	var getStationMessage_ = function(){
   		setInterval(function(){
   			getStationMessage();
   	  	},10000);
   	}
   	
   	function getStationMessage() {
   		$.dpAjax({
   			show:false,
   			url:'${basePath}/SystemController/getOtherInboxMapperList',
   			success: function(datas)
   			{ 
   				 var html = "";
				 var otherInbox = datas.result.result;
				 var amountCount = datas.result.count;
				 $("#amountCount").text(amountCount);
				 if(otherInbox && otherInbox.length > 0)
				 {	
					 for(var i in otherInbox)
					 {	
						 var record = otherInbox[i];
						 var contentInbox = record.contentInbox;
						 var statusInbox = record.statusInbox;
						 var recordName = record.titleInbox.split('>')[0].replace("<","");
						 var lastTwoname = recordName.substring((recordName.length-2),(recordName.length));
						 html += "<li><div class='content'><div class='row rowmargin'><div class='col-xs-8 col-sm-8 col-md-8 col-lg-8 textOverflow'><a class='colorOtherInbox' href='javascript:void(0);' onclick='showOtherInbox(this);' id='" + record.replaceId + "' value='"+contentInbox+"' attrtitle='"+record.titleInbox+"' class='fontwidth' title='查看详情'>";
						 html += "<span class='imgbackcolor'>"+lastTwoname+"</span>";
						 html += record.titleInbox + "</a></div><div class='col-xs-4 col-sm-4 col-md-4 col-lg-4 choiceStyle'><div class='dbsx-contenttime'>";
						 if(statusInbox=="1"){
							 html += formateIntegerTime(record.created,'yyyy-MM-dd') + "<span class='Countoneyuan'></span></div></div></li>";
						 }else if(statusInbox=="2"){
							 html += formateIntegerTime(record.created,'yyyy-MM-dd') + "<span class='CountoneStyle'></span></div></div></li>";
						 }
					 }
				 }
				 $('#otherInbox-content').html(html);
			 	 return;
            }
   	   	});
   	}
   	
    //展示邮件详情
    function showOtherInbox(liObject)
    {
    	var value = $(liObject).attr('value');
    	var title = $(liObject).attr('attrtitle');
    	var id = $(liObject).attr('id');
    	if(!value || value == '') {
    		return;
    	}
    	
    	upOtherInbox(id);
    	
    	//清除样式
    	setTimeout(function(){
    		$(liObject).parent().siblings(".choiceStyle").find("span").removeClass("Countoneyuan").addClass("CountoneStyle");
    	},10000);
    	
    	layer.open({
			  type: 1,
			  title:'标题：' + title,
			  skin: 'layui-layer-lan',
			  area: ['500px', '500px'], //宽高
			  content: $('#emailContent')
		});
    	$("#emailcontent-con").html(value);
    }
    
   </script>
</body>